<include file="Common:header" />
<!-- /. NAV SIDE  -->
<include file="Common:left" />
<!-- /. NAV SIDE  -->
<style>
	.goodcss1{
		white-space:nowrap;
	}
	.goodsimgcss{
		width:50px;
	}
	.avatarurl{
		width:30px;
		border-radius:50%;
      height: 30px;
	}
	.fontcssgreen{
		color:#009688
	}
	.fontcssred{
		color:#f36a5a
	}
	.commissioncss{
		line-height:21px;
	}
</style>
<div id="page-wrapper">
	<div class="header">
		<h1 class="page-header">
			订单管理 <small>Welcome {$Think.config.system_tag}</small>
		</h1>
		<ol class="breadcrumb">
			<li><a href="{:U('Index/index')}">首页</a></li>
			<li class="active">订单列表</li>
			<div style="float:right"></div>
		</ol> 
	</div>
	<div id="page-inner">
		<div class="row">
			<div class="col-xs-12">
				<!--Search content-->
				<div class="panel panel-default" style="margin-bottom:0px; border-bottom:none">
					<div class="panel-body">
						<form class="layui-form" action="{:U('Orders/ordersList')}" method="post">
							<div class="layui-form-item">
								<label class="layui-form-label" style="width:auto;">订单号</label>
								<div class="layui-input-inline">
									<input value="{$filter.order_id}" type="text" name="order_id" placeholder="请输入订单号" autocomplete="off" class="layui-input">
								</div>
								<label class="layui-form-label" style="width:auto;">用户名</label>
								<div class="layui-input-inline">
									<input value="{$filter.user_name}" type="text" name="user_name" placeholder="请输入用户名" autocomplete="off" class="layui-input">
								</div>
								<label class="layui-form-label" style="width:auto;">状态</label>
								<div class="layui-input-inline">
									<select name="status" lay-verify="">
										<option value="">请选择</option>
										<notempty name="orderStatusList">
											<volist name="orderStatusList" id="vo">
												<option value="{$vo.value}" <if condition="($filter['status'] eq $vo['value'])">selected</if>>{$vo.name}</option>
											</volist>
										</notempty>
									</select>
								</div>
								<label class="layui-form-label" style="width:auto;">是否同步</label>
								<div class="layui-input-inline">
									<select name="sync_status" lay-verify="">
										<option value="">请选择</option>
										<notempty name="syncStatusList">
											<volist name="syncStatusList" id="vo">
												<option value="{$vo.value}" <if condition="($filter['sync_status'] eq $vo['value'])">selected</if>>{$vo.name}</option>
											</volist>
										</notempty>
									</select>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label" style="width:auto;">下单时间</label>
								<div class="layui-input-inline">
									<input id="addtime_fromdate" value="{$filter.addtime_fromdate}" type="text" name="addtime_fromdate" placeholder="请输入下单起始时间" autocomplete="off" class="layui-input">
								</div>
								<div class="layui-input-inline">
									<input id="addtime_todate" value="{$filter.addtime_todate}" type="text" name="addtime_todate" placeholder="请输入下单结束时间" autocomplete="off" class="layui-input">
								</div>
								<div class="layui-input-inline" style="width:auto;">
									<button type="submit" class="btn btn-default">搜索</button>
								</div>
							</div>
						</form>
					</div>
				</div>
				<!--Search content-->
				<!--Formlist content-->
				<div class="panel panel-default">
					<div class="panel-body">
						<div class="table-responsive">
							<table class="table table-hover">
								<thead>
									<tr>
									    <th><input type="checkbox" onclick="checkall()" /></th>
										<th class="goodcss1">订单号</th>
										<th class="goodcss1">头像</th>
										<th class="goodcss1">所属用户</th>
										<th class="goodcss1">订单总金额</th>
										<th class="goodcss1">支付金额</th>
										<th class="goodcss1">订单状态</th>
										<th class="goodcss1">下单时间</th>
										<th class="goodcss1">操作</th>
									</tr>
								</thead>
								<tbody>
									<volist name="ordersList" id="vo">
										<tr>
										    <td><input type="checkbox" name="selectprint" value="{$vo.order_id}" /></td>
											<td class="goodcss1">{$vo.order_id}</td>
											<td class="goodcss1"><img src="{$vo.avatarurl}" border="0" class="avatarurl"></td>
											<td class="goodcss1">{$vo.username}</td>
											<td class="goodcss1">{$vo.total_amount}</td>
											<td class="goodcss1">{$vo.pay_price}</td>
											<td class="goodcss1">
											    <if condition="$vo['status'] eq 1">
											        待支付
											    <elseif condition="$vo['status'] eq 2" />
											        待发货
											    <elseif condition="$vo['status'] eq 3" />
											        已发货
											    <elseif condition="$vo['status'] eq 4" />
											        已收货
											    <elseif condition="$vo['status'] eq 5" />
											        已取消
											    <elseif condition="$vo['status'] eq 6" />
											        待退款
											    </if>
											</td>
											<td class="goodcss1">{$vo['addtime']}</td>
											<td class="goodcss1">
												<button class="layui-btn layui-btn-xs" onclick="openlayer('订单详情','{:U('Orders/orderDetail',array('id'=>$vo['id']))}');return false;">详</button>
												<if condition="$vo['status'] eq 2">
												    <a href="#" class="layui-btn layui-btn-xs layui-btn-normal" onclick="openlayer('手动发货','{:U('Orders/deliverOrder',array('id'=>$vo['id']))}');return false;">手动发货</a>
												</if>
												<if condition="$vo['status'] eq 3">
												    <a href="#" class="layui-btn layui-btn-xs layui-btn-normal" onclick="if(confirm('确认货已收到吗？')){ajaxBox('{:U('Orders/confirmOrder',array('id'=>$vo['id']))}')}return false;">确认收货</a>
												</if>
                                    <if condition="in_array($vo['status'],[0,1,2])">
                                       <a href="#" class="layui-btn layui-btn-danger layui-btn-xs layui-btn-normal" onclick="if(confirm('确定要取消吗？')){ajaxBox('{:U('Orders/cancelOrder',array('id'=>$vo['id']))}')}return false;">取消订单</a>
                                   </if>
											</td>
										</tr>
									</volist>
									<tr>
										<td colspan="9">
											<if condition="($filter['status'] eq 2)">
											    <if condition="($filter['sync_status'] eq 0)">
											        <a id="sendOrder" href="javascript:void(0)" title="批量推送订单">批量推送订单</a>
											    <elseif condition="($filter['sync_status'] eq 1)" />
											        <a id="getOrderDelivery" href="javascript:void(0)" title="批量获取运单号">批量获取运单号</a>
											    </if>
											</if>
										</td>
									</tr>
								</tbody>
							</table>
							{$page}
						</div>
					</div>
				</div>
				<!--Formlist content-->
			</div>
		</div>
	</div>
	<include file="Common:foot" />
	<script>
		layui.use('form', function(){
		  var form = layui.form;
		});
	</script>
	<script type="text/javascript">
		$('#sendOrder').click(function(){
			var $checkList = $("input[name='selectprint']");
			var gid_str = '';
			$checkList.each(function(){
				if($(this).get(0).checked){
					gid_str+=$(this).val()+'_';
				}
			});
			if(!gid_str){
				alert('请选择订单！');
				return false;
			}
			ajaxBox('__URL__/batchSendOrder/order_id/'+gid_str);
		});
		$('#getOrderDelivery').click(function(){
			var $checkList = $("input[name='selectprint']");
			var gid_str = '';
			$checkList.each(function(){
				if($(this).get(0).checked){
					gid_str+=$(this).val()+'_';
				}
			});
			if(!gid_str){
				alert('请选择订单！');
				return false;
			}
			ajaxBox('__URL__/batchGetOrderDelivery/order_id/'+gid_str);
		});
	</script>
	 <!-- /. PAGE INNER  -->
</div>
<include file="Common:footer" />
    